<?php

namespace App\Containers\AppSection\BankDetail\UI\API\Controllers;

use App\Containers\AppSection\BankDetail\Actions\ChangeMasterAccountAction;
use App\Containers\AppSection\BankDetail\Actions\CreateBankDetailAction;
use App\Containers\AppSection\BankDetail\Actions\DeleteBankDetailAction;
use App\Containers\AppSection\BankDetail\Actions\UpdateBankDetailAction;
use App\Containers\AppSection\BankDetail\UI\API\Requests\ChangeMasterAccountRequest;
use App\Containers\AppSection\BankDetail\UI\API\Requests\CreateBankDetailRequest;
use App\Containers\AppSection\BankDetail\UI\API\Requests\DeleteBankDetailRequest;
use App\Containers\AppSection\BankDetail\UI\API\Requests\UpdateBankDetailRequest;
use App\Containers\AppSection\BankDetail\UI\API\Transformers\BankDetailTransformer;
use App\Ship\Parents\Controllers\ApiController;
use Illuminate\Http\JsonResponse;

class Controller extends ApiController
{
    public function createBankDetail(CreateBankDetailRequest $request): JsonResponse
    {
        $bankDetail = app(CreateBankDetailAction::class)->run($request);

        return $this->created($this->transform($bankDetail, BankDetailTransformer::class));
    }

    public function updateBankDetail(int $id, UpdateBankDetailRequest $request): JsonResponse
    {
        app(UpdateBankDetailAction::class)->run($id, $request);

        return $this->noContent();
    }

    public function deleteBankDetail(int $id, DeleteBankDetailRequest $request): JsonResponse
    {
        app(DeleteBankDetailAction::class)->run($id, $request);

        return $this->noContent();
    }

    public function changeMasterAccount(int $id, ChangeMasterAccountRequest $request): JsonResponse
    {
        app(ChangeMasterAccountAction::class)->run($id, $request);

        return $this->noContent();
    }
}
